

namespace gen {

    ///////////////////////////////////////////////////////////////////////////
    //
    //  char_generator class
    //
    ///////////////////////////////////////////////////////////////////////////
    template <typename DerivedT>
    template <typename InfoT>
	void
	char_generator<DerivedT>::generate(InfoT & info) const
    {
		info.append(this->derived().get());
    }

    ///////////////////////////////////////////////////////////////////////////
    //
    //  chlit class
    //
    ///////////////////////////////////////////////////////////////////////////
    template <typename CharT>
    inline chlit<CharT>
    ch_g(CharT ch)
    { 
        return chlit<CharT>(ch); 
    }

    // This should take care of ch_g("a") "bugs"
    template <typename CharT, std::size_t N>
    inline chlit<CharT>
    ch_g(CharT const (& str)[N])
    {
        //  ch_p's argument should be a single character or a null-terminated
        //  string with a single character
        BOOST_STATIC_ASSERT(N < 3);
        return chlit<CharT>(str[0]);
    }

	///////////////////////////////////////////////////////////////////////////
    //
    //  chseq class
    //
    ///////////////////////////////////////////////////////////////////////////
    template <typename CharIteratorT>
    template <typename InfoT>
    inline void
	chseq<CharIteratorT>::generate(InfoT & info) const
    {
        typedef typename generator_result<typename InfoT::char_t>::str_type		result_t;
		typedef typename boost::unwrap_reference<CharIteratorT>::type			striter_t;
		info.append(result_t(striter_t(first), striter_t(last)));
    }

    template <typename CharT>
    inline chseq<CharT const*>
    chseq_g(CharT const* str)
    { 
        return chseq<CharT const*>(str); 
    }

    template <typename CharIteratorT>
    inline chseq<CharIteratorT>
    chseq_g(CharIteratorT first, CharIteratorT last)
    { 
        return chseq<CharIteratorT>(first, last); 
    }

    ///////////////////////////////////////////////////////////////////////////
    //
    //  strlit class
    //
    ///////////////////////////////////////////////////////////////////////////
    template <typename CharIteratorT>
	template <typename InfoT>
	inline void
	strlit<CharIteratorT>::generate(InfoT & info) const
	{
		seq.generate(info);
	}

    template <typename CharT>
    inline strlit<CharT const*>
    str_g(CharT const* str)
    { 
        return strlit<CharT const*>(str); 
    }

    template <typename CharT>
    inline strlit<CharT *>
    str_g(CharT * str)
    { 
        return strlit<CharT *>(str); 
    }

    template <typename CharIteratorT>
    inline strlit<CharIteratorT>
    str_g(CharIteratorT first, CharIteratorT last)
    { 
        return strlit<CharIteratorT>(first, last); 
    }

	// This should take care of str_g(string("a"))
    template <typename CharIteratorT>
	template <typename InfoT>
	inline void
	strlit< basic_string<CharIteratorT> >::generate(InfoT & info) const
	{
		seq.generate(info);
	}

    template <typename CharT>
    inline strlit< basic_string<CharT> >
    str_g(basic_string<CharT> str)
    { 
        return strlit< basic_string<CharT> >(str); 
    }

    // This should take care of str_g('a') "bugs"
    template <typename CharT>
    inline chlit<CharT>
    str_g(CharT ch)
    {
        return chlit<CharT>(ch);
    }

    ///////////////////////////////////////////////////////////////////////////
    //
    //  lower class
    //
    ///////////////////////////////////////////////////////////////////////////
    template <typename CharT>
    inline lower_generator<CharT>
    lower_g(CharT ch)
    { 
        return lower_generator<CharT>(ch); 
    }

    // This should take care of lower_g("a") "bugs"
    template <typename CharT, std::size_t N>
    inline lower_generator<CharT>
    lower_g(CharT const (& str)[N])
    {
        //  ch_p's argument should be a single character or a null-terminated
        //  string with a single character
        BOOST_STATIC_ASSERT(N < 3);
        return lower_generator<CharT>(str[0]);
    }

    ///////////////////////////////////////////////////////////////////////////
    //
    //  upper class
    //
    ///////////////////////////////////////////////////////////////////////////
    template <typename CharT>
    inline upper_generator<CharT>
    upper_g(CharT ch)
    { 
        return upper_generator<CharT>(ch); 
    }

    // This should take care of upper_g("a") "bugs"
    template <typename CharT, std::size_t N>
    inline upper_generator<CharT>
    upper_g(CharT const (& str)[N])
    {
        //  ch_p's argument should be a single character or a null-terminated
        //  string with a single character
        BOOST_STATIC_ASSERT(N < 3);
        return upper_generator<CharT>(str[0]);
    }

}
